package com.canyou.model;

import java.util.ArrayList;
import java.util.List;

import com.jfinal.log.Logger;
import com.jfinal.plugin.activerecord.ActiveRecordException;
import com.jfinal.plugin.activerecord.Model;

/**
 * 参数
 * <p>
 * [Id] ,[TypeNo]（2：技能等级；4：学历） ,[TypeName] ,[ParamText]
 * 
 * @created cgz 2012-12-19
 */
public class Param extends Model<Param> {

	private static final long serialVersionUID = 3541512798118615314L;

	private static Logger logger = Logger.getLogger(Param.class);

	public static final Param dao = new Param();

	/**
	 * 根据参数类型获取参数列表
	 * 
	 * @author cgz 2012-12-19
	 * @param no
	 *            参数类型(2：技能等级；4：学历)
	 * @return
	 */
	public List<Param> getListByType(int no) {
		List<Param> list = new ArrayList<Param>();
		if (no > 1) {
			try {
				list = find("select * from Public_Param_tb where TypeNo = ?",
						no);
			} catch (ActiveRecordException e) {
				logger.error(e.getMessage(), e);
			}
		}
		return list;
	}

	/**
	 * 根据ID获取参数名称
	 * 
	 * @author cgz 2012-12-23
	 * @param id
	 * @return
	 */
	public String getTextById(int id) {
		Param param = null;
		if (id > 0) {
			try {
				param = findById(id, "ParamText");
			} catch (ActiveRecordException e) {
				logger.error(e.getMessage(), e);
			}
		}
		return null == param ? "未知" : param.getStr("ParamText");
	}
}
